<?php
//
// 功能说明：记录列表
// $Id: home.php 22 2012-12-13 10:05:40Z jiangbianwanghai@gmail.com $
//
header("Content-type:text/html;charset=utf-8");
date_default_timezone_set('PRC');
require_once './conf/config.php';
require_once './class/db.class.php';
require_once './class/dateformat.class.php';

$mod = isset($_GET['mod']) ? $_GET['mod'] : 'track';
$act = isset($_GET['act']) ? $_GET['act'] : 'list';
include './include/'.$mod.'.mod.php';
exit();
if (isset($_GET['tid']) && !empty($_GET['tid']) && is_numeric($_GET['tid'])) {
	$rs = array();
	//获得事件详情
	$tid = abs(intval($_GET['tid']));
	$sql = "SELECT * FROM `".$_C['DB']['PREFIX']."tracks` WHERE `tid` = '".$tid."'";
	$result = $conn->query($sql);
	$track = $result->fetch_array(MYSQLI_ASSOC);
	//获得反馈详情
	$sql = "SELECT * FROM `".$_C['DB']['PREFIX']."reports` WHERE `tid` = '".$tid."' AND `uid` = '1' ORDER BY rid DESC LIMIT 10";
	$result = $conn->query($sql);
	while($row = $result->fetch_array(MYSQLI_ASSOC)) {
		$rs[] = $row;
	}
	require_once './template/tracks-view.temp.php';
} else {
	//获取页码
	if (isset($_GET['page']) && !empty($_GET['page']) && is_numeric($_GET['page'])) {
		$page = abs(intval($_GET['page']));
	} else {
		$page = 0;
	}
	//获取页数
	if (isset($_GET['pagenum']) && !empty($_GET['pagenum']) && is_numeric($_GET['pagenum'])) {
		$pagenum = abs(intval($_GET['pagenum']));
	} else {
		$sql = "SELECT count(*) FROM `".$_C['DB']['PREFIX']."tracks` WHERE `uid` = '1'";
		$result = $conn->query($sql);
		$row = $result->fetch_row();
		$pagenum = ceil($row[0]/$_C['COMMON']['pagesize']);
	}

	$offset = $page*$CONFIG['pagesize'];
	$sql = "SELECT * FROM `".$_C['DB']['PREFIX']."tracks` WHERE `uid` = '1' ORDER BY tid DESC LIMIT ".$offset.", ".$_C['COMMON']['pagesize'];
	$result = $conn->query($sql);
	while($row = $result->fetch_array(MYSQLI_ASSOC)) {
		$rs[] = $row;
	}
	require_once './template/home.temp.php';
}